package com.example.second.mediator.classes;

import com.example.second.mediator.interfaces.IColleague;
import com.example.second.mediator.interfaces.IMediator;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName: ConcreteMediator$
 * @Description: java类作用描述
 * @Author: xinya
 * @CreateDate: 2020/12/23$ 14:39$
 * @UpdateRemark: 更新内容
 * @Version: 1.0
 */
public class ConcreteMediator implements IMediator {
    List<IColleague> mColleagueList = new ArrayList<>();
    @Override
    public void register(IColleague colleague) {
        mColleagueList.add(colleague);
    }

    @Override
    public void relay(String message, IColleague colleague) {
        for (IColleague client : mColleagueList) {
            if (client == colleague) continue;
            client.receive(message);
        }
    }
}
